﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ERPStore.Models
{
	internal static class ModelsExtensions
	{
		internal static int DeepProductCount<T>(this IEnumerable<T> list)
	where T : Models.ProductCategory
		{
			var result = 0;
			if (list != null && list.Count() > 0)
			{
				foreach (var item in list)
				{
					result += item.ProductCount + DeepProductCount(item.Children);
				}
			}
			return result;
		}

	}
}
